package com.ft.oa.web.sys;

import com.ft.oa.domain.dto.ApiResult;
import com.github.benmanes.caffeine.cache.Cache;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/sys")
public class LogoutController {

    @Resource
    private Cache<String, Object> caffeineCache;

    @GetMapping("/logout")
    public ApiResult logout(HttpServletRequest request){
        String token = request.getHeader("token");
        caffeineCache.put(token, 0);
        return ApiResult.simpleSuccess();
    }
}
